package pantomime.gestures;
import processing.core.*;
import java.util.ArrayList;

public class GestureCollection{
	
	private ArrayList<Gesture> alGestures;
	
	/**
	 * Initialize an empty GestureCollection
	 */
	public GestureCollection(){
		this.alGestures = new ArrayList<Gesture>();
	}
	
	/**
	 * Initialize a GestureCollection from an ArrayList of gestures
	 * @param alGesutres
	 */
	public GestureCollection(ArrayList<Gesture> alGesutres){
		this.alGestures = alGestures;
	}
	
	/**
	 * Initialize
	 * @param parent - The PApplet this constructor is called from. Usually 'this'
	 * @param sXMLPath - The String path to the XML file containing gesture definitions
	 */
	public GestureCollection(PApplet parent, String sXMLPath){
		this.alGestures = GestureLoader.getGesturesFromXML(parent, sXMLPath);
	}
	
	public void addGesture(Gesture oGesture){
		this.alGestures.add(oGesture);
	}
	
	public Gesture getGesture(int index){
		if (index < 0){
			return new StaticGesture();
		}
		return alGestures.get(index);
	}
	
	public void removeGesture(Gesture oGesture){
		this.alGestures.remove(oGesture);
	}
	
	public void removeAt(int index){
		alGestures.remove(index);
	}
	
	public int size(){
		return alGestures.size();
	}
	
	/**
	 * Custom toString(). Prints each Gesture.toString (defined in gesture class) in its own line.
	 */
	public String toString(){
		String sReturn = "";
		for(Gesture oGest : alGestures){
			sReturn += oGest.toString() + "\n";
		}
		return sReturn;
	}
}
